package com.sunnada.edu.system.sysarea.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.sunnada.edu.system.pub.dao.BaseDaoImpl;

@Repository
public class AreaDaoImpl extends BaseDaoImpl implements AreaDao {
	@Override
	public List<?> areaTree(HashMap<String, String> params) {
		return selectList("area_sqlmap.areaTree", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public int getAreaCots(HashMap<String, String> params) {
		List list = selectList("area_sqlmap.getAreaCots", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("COT") + "";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findAreas(HashMap<String, String> params) {
		return selectList("area_sqlmap.findAreas", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map getAreaByAreacord(HashMap<String, String> params) {
		List list = selectList("area_sqlmap.getAreaByAreacode", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String areaTreebig(HashMap<String, String> params) {
		List list = selectList("area_sqlmap.areaTreebig", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("AREA_CODE") + "";
			return cot;
		}
		return "0";
	}

	@Override
	public int areaAdd(HashMap<String, String> params) {
		return insert("area_sqlmap.areaAdd", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map getAreaByRecId(HashMap<String, String> params) {
		List list = selectList("area_sqlmap.getAreaByRecId", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map areaByAreacode(HashMap<String, String> params) {
		List list = selectList("area_sqlmap.getAreaByAreacode", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@Override
	public int areaUpdate(HashMap<String, String> params) {
		return update("area_sqlmap.areaUpdate", params);
	}

	@Override
	public int areaDel(HashMap<String, String> params) {
		return delete("area_sqlmap.areaDel", params);
	}

	@Override
	public int areaEnable(HashMap<String, String> params) {
		return update("area_sqlmap.areaEnable", params);
	}

	@Override
	public int areaDisable(HashMap<String, String> params) {
		return update("area_sqlmap.areaDisable", params);
	}

	@Override
	public int areaContrastAdd(HashMap<String, String> params) {
		return insert("area_sqlmap.areaContrastAdd", params);
	}

}
